﻿<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <CustomAction
     Id="AddEmployeeForm"
     RegistrationType="List"
     RegistrationId="10000"
     Location="CommandUI.Ribbon.DisplayForm">
    <CommandUIExtension>
      <CommandUIDefinitions>
        <CommandUIDefinition Location="Ribbon.ListForm.Display.Actions.Controls._children">
          <Button
            Id="Ribbon.ListForm.Display.Actions.AddEmployeeForm"
            Command="Sapiens.PageComponent.Command.AddEmployeeForm"
            Image16by16="/_layouts/1031/images/formatmap16x16.png"
            Image16by16Top="-192"
            Image16by16Left="-160"
            Image32by32="/_layouts/1031/images/formatmap32x32.png"
            Image32by32Top="-160"
            Image32by32Left="-288"
            LabelText="Add new employee"
            ToolTipTitle="Add new employee"
            ToolTipDescription="Opens a form to create a new employee using this department."
            TemplateAlias="o1"/>
        </CommandUIDefinition>
      </CommandUIDefinitions>
    </CommandUIExtension>
  </CustomAction>

  <CustomAction
     Id="AddEmployee"
     RegistrationType="List"
     RegistrationId="10000"
     Location="CommandUI.Ribbon">
    <CommandUIExtension>
      <CommandUIDefinitions>
        <CommandUIDefinition Location="Ribbon.ListItem.Actions.Controls._children">
          <Button
            Id="Ribbon.ListItem.Actions.AddEmployee"
            Command="Sapiens.PageComponent.Command.AddEmployee"
            Image16by16="/_layouts/1031/images/formatmap16x16.png"
            Image16by16Top="-192"
            Image16by16Left="-160"
            Image32by32="/_layouts/1031/images/formatmap32x32.png"
            Image32by32Top="-160"
            Image32by32Left="-288"
            LabelText="Add new employee"
            ToolTipTitle="Add new employee"
            ToolTipDescription="Opens a form to create a new employee using this department."
            TemplateAlias="o1"/>
        </CommandUIDefinition>
      </CommandUIDefinitions>
      <CommandUIHandlers>
        <CommandUIHandler
          Command="Sapiens.PageComponent.Command.AddEmployee"
          EnabledScript="javascript:singleItemSelected();"
          CommandAction="javascript:
            var selectedId = SP.ListOperation.Selection.getSelectedItems()[0].id;
            var options = {
		          url: '../../Lists/Employees/NewForm.aspx?Source=' + encodeURIComponent(window.location.href + '?SelectedID=' + selectedId),
	          };
	          SP.UI.ModalDialog.showModalDialog(options);
          " />
      </CommandUIHandlers>
    </CommandUIExtension>
  </CustomAction>
</Elements>
